package com.jzone.teacherajax.mapper;

import com.jzone.teacherajax.pojo.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherMapper {

    // ��ӽ�ʦ
    @Insert("INSERT INTO teachers(employee_id, name, gender, subject, email, phone, salary, department, address, is_active) " +
            "VALUES (#{employeeId}, #{name}, #{gender}, #{subject}, #{email}, #{phone}, #{salary}, #{department}, #{address}, #{isActive})")
    void add(Teacher teacher);

    // ���½�ʦ��Ϣ
    @Update("UPDATE teachers SET employee_id=#{employeeId}, name=#{name}, gender=#{gender}, subject=#{subject}, " +
            "email=#{email}, phone=#{phone}, salary=#{salary}, department=#{department}, address=#{address}, " +
            "is_active=#{isActive} WHERE id=#{id}")
    void update(Teacher teacher);

    // ɾ����ʦ
    @Delete("DELETE FROM teachers WHERE id=#{id}")
    void delete(Integer id);

    // ��ѯ���н�ʦ
    @Select("SELECT * FROM teachers")
    List<Teacher> getAllTeachers();

    // ���� employeeId ��ѯ��ʦ
    @Select("SELECT * FROM teachers WHERE employee_id=#{employeeId}")
    Teacher getTeacherByEmployeeId(Integer employeeId);

    @Select("SELECT COUNT(*) FROM teachers")
    int getTeacherCount();
}
